package com.mfw.springboot.model.vo;

import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.mfw.springboot.model.entity.UserTrainingPlanRelation;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 用户训练计划关系视图
 *
 * @author mfw
 * @from <a href="https://gitee.com/hanhuaifei/projects">我的gitee</a>
 * @Date 2024/9/26
 */
@Data
public class UserTrainingPlanRelationVO implements Serializable {

    /**
     * id
     */
    private Long id;

    /**
     * 用户ID
     */
    private Long userId;

    /**
     * 训练计划ID
     */
    private Long planId;

    /**
     * 加入时间
     */
    private Date joinTime;

    /**
     * 状态: ongoing/completed
     */
    private String status;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 更新时间
     */
    private Date updateTime;


    private static final long serialVersionUID = 1L;

    /**
     * 用户信息
     */
    private UserVO user;

    /**
     * 训练计划信息
     */
    private TrainingPlanVO trainingPlan;

    /**
     * 封装类转对象
     *
     * @param userTrainingPlanRelationVO
     * @return
     */
    public static UserTrainingPlanRelation voToObj(UserTrainingPlanRelationVO userTrainingPlanRelationVO) {
        if (userTrainingPlanRelationVO == null) {
            return null;
        }
        UserTrainingPlanRelation userTrainingPlanRelation = new UserTrainingPlanRelation();
        BeanUtils.copyProperties(userTrainingPlanRelationVO, userTrainingPlanRelation);
        return userTrainingPlanRelation;
    }

    /**
     * 对象转封装类
     *
     * @param userTrainingPlanRelation
     * @return
     */
    public static UserTrainingPlanRelationVO objToVo(UserTrainingPlanRelation userTrainingPlanRelation) {
        if (userTrainingPlanRelation == null) {
            return null;
        }
        UserTrainingPlanRelationVO userTrainingPlanRelationVO = new UserTrainingPlanRelationVO();
        BeanUtils.copyProperties(userTrainingPlanRelation, userTrainingPlanRelationVO);
        return userTrainingPlanRelationVO;
    }
}
